#ifndef TUPDATEDIALOG_H
#define TUPDATEDIALOG_H

#include <QDialog>
#include <QNetworkAccessManager>
#include <QNetworkRequest>
#include <QNetworkReply>
#include <QJsonDocument>
#include <QJsonObject>
#include <QFile>
#include <QProcess>
#include <QCoreApplication>
#include <QtCore/private/qzipreader_p.h>
#include <QtCore/private/qzipwriter_p.h>
#include <QFileInfo>
#include <QDir>
#define TOOLSVERSION "V3.0.4"
namespace Ui {
class TupdateDialog;
}

class TupdateDialog : public QDialog
{
    Q_OBJECT

public:
    explicit TupdateDialog(QWidget *parent = nullptr);
    ~TupdateDialog();
    void checkForUpdate();
    void downloadUpdate(const QString &url);
    void applyUpdate();
    void zip_compress(const QStringList &fileNames, const QString &path);
    void zip_decompress(const QString &fileName, const QString &path);
private slots:
    void onUpdateCheckFinished(QNetworkReply *reply);
    void onUpdateDownloadFinished(QNetworkReply *reply);

    void on_btnUpgrade_clicked();

private:
    Ui::TupdateDialog *ui;
    QString latestVersion;
    QString downloadUrl;
};

#endif // TUPDATEDIALOG_H
